package net.csdn.bigc2001.lockmyphone;

import android.app.admin.DeviceAdminReceiver;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Handler;
import android.preference.PreferenceManager;
import android.util.Log;

public class MyDeviceAdminReceiver extends DeviceAdminReceiver {
    private static final String tag = "+>DeviceAdminReceiver";

    @Override
    public void onReceive(Context context, Intent intent) {
        super.onReceive(context, intent);
        Log.d(tag, "设备管理：onReceive");
    }

    @Override
    public void onEnabled(Context context, Intent intent) {
        // 设备管理：可用
        Log.d(tag, "设备管理：可用");
        PreferenceManager.getDefaultSharedPreferences(context).edit().putString(MainActivity.FLAG, "1").apply();
    }

    @Override
    public void onDisabled(final Context context, Intent intent) {
        // 设备管理：不可用
        Log.d(tag, "设备管理：不可用");
    }

    @Override
    public CharSequence onDisableRequested(Context context, Intent intent) {
        Log.d(tag, "==onDisableRequested");
        return "onDisableRequested";
    }

}